//
//  HomePageTitleView.m
//  PYWGetColor
//
//  Created by 杜文杰 on 2018/5/24.
//  Copyright © 2018年 dwj. All rights reserved.
//

#import "HomePageTitleView.h"
@interface HomePageTitleView()<UITextFieldDelegate>

@end

@implementation HomePageTitleView
- (void)topBtnAction:(UIButton *)btn
{
    if (self.topBtnClickBlock) {
        self.topBtnClickBlock();
    }
}

- (instancetype)initWithFrame:(CGRect)frame
{
    if (self = [super initWithFrame:frame]) {
       
        [self setUpViews];
    }
    return self;
}

- (void) setUpViews
{
    // 用户头像
    UIButton *userImageBtn = [[UIButton alloc] initWithFrame:CGRectMake(10 / WIDTH_6S_SCALE,(self.bounds.size.height - 44 / HEIGHT_6S_SCALE) * 0.5, 44 / HEIGHT_6S_SCALE, 44 / HEIGHT_6S_SCALE)];
    [userImageBtn setImage:[UIImage imageNamed:@"nav_info"] forState:UIControlStateNormal];
    [userImageBtn addTarget:self action:@selector(userImageBtn:) forControlEvents:UIControlEventTouchUpInside];
    [self addSubview:userImageBtn];
    
    // 定位按钮
    UIButton *locationBtn = [[UIButton alloc] initWithFrame:CGRectMake(userImageBtn.frame.origin.x + 56 / WIDTH_6S_SCALE,(self.bounds.size.height - 36 / HEIGHT_6S_SCALE) * 0.5, 70 / HEIGHT_6S_SCALE, 36 / HEIGHT_6S_SCALE)];
    [locationBtn setImage:[UIImage imageNamed:@"nav_sj"] forState:UIControlStateNormal];
    [locationBtn setTitle:@"定位" forState:UIControlStateNormal];
    [locationBtn setTitleColor:getColor(blackColor) forState:UIControlStateNormal];
    locationBtn.titleLabel.font = DEF_FontSize_14;
    locationBtn.layer.borderColor = getColor(dividerColor).CGColor;
    locationBtn.layer.borderWidth = 0.5;
    locationBtn.imageEdgeInsets = UIEdgeInsetsMake(0, 55 / WIDTH_6S_SCALE, 0, 0);
    locationBtn.titleEdgeInsets = UIEdgeInsetsMake(0, 0, 0, 15 / WIDTH_6S_SCALE);
    self.locationBtn = locationBtn;
    [locationBtn addTarget:self action:@selector(locationBtn:) forControlEvents:UIControlEventTouchUpInside];
    [self addSubview:locationBtn];
    
//    UITextField *searTextField = [[UITextField alloc]initWithFrame:CGRectMake(locationBtn.frame.origin.x + locationBtn.bounds.size.width,(self.bounds.size.height - 36 / HEIGHT_6S_SCALE) * 0.5, 190 / HEIGHT_6S_SCALE, 36 / HEIGHT_6S_SCALE)];
//    searTextField.backgroundColor = [UIColor clearColor];
//    searTextField.font = DEF_FontSize_14;
//    searTextField.delegate = self;
//    searTextField.placeholder = @" 找工作  找房子  找服务";
//    searTextField.layer.borderColor = getColor(dividerColor).CGColor;
//    searTextField.layer.borderWidth = 0.5;
//    [searTextField addTarget:self action:@selector(searTextFieldClick) forControlEvents:UIControlEventEditingDidBegin];
//    [self addSubview:searTextField];
    
    UIButton *topBtn = [[UIButton alloc]initWithFrame:CGRectMake(locationBtn.frame.origin.x + locationBtn.bounds.size.width,(self.bounds.size.height - 36 / HEIGHT_6S_SCALE) * 0.5, 190 / HEIGHT_6S_SCALE, 36 / HEIGHT_6S_SCALE)];
    topBtn.backgroundColor = [UIColor clearColor];
    [topBtn setTitleColor:getColor(textColor) forState:UIControlStateNormal];
    topBtn.titleLabel.font = DEF_FontSize_14;
    topBtn.layer.borderColor = getColor(dividerColor).CGColor;
    topBtn.layer.borderWidth = 0.5;
    [topBtn setTitle:@" 找工作  找房子  找服务" forState:UIControlStateNormal];
    [topBtn addTarget:self action:@selector(topBtnAction:) forControlEvents:UIControlEventTouchUpInside];
    [self addSubview:topBtn];
    // 消息
    UIButton *newsInfoMationBtn = [[UIButton alloc] initWithFrame:CGRectMake(SCREEN_WIDTH - 44/ WIDTH_6S_SCALE,(self.bounds.size.height - 44 / HEIGHT_6S_SCALE) * 0.5, 44 / HEIGHT_6S_SCALE, 44 / HEIGHT_6S_SCALE)];
    [newsInfoMationBtn setImage:[UIImage imageNamed:@"nav_news"] forState:UIControlStateNormal];
    [newsInfoMationBtn addTarget:self action:@selector(newsInfoMationBtn:) forControlEvents:UIControlEventTouchUpInside];
    [self addSubview:newsInfoMationBtn];
}

- (void)userImageBtn:(UIButton *)btn
{
    if (self.userImageClcik) {
        self.userImageClcik();
    }
}
- (void)locationBtn:(UIButton *)btn
{
    if (self.locationBtnClick) {
        self.locationBtnClick();
    }
}
- (void)newsInfoMationBtn:(UIButton *)btn
{
    if (self.newsBtnClick) {
        self.newsBtnClick();
    }
}
@end
